/**
 * @author 施钦文
 */
public class UserTools {
    /**
     * 合格分数
     */
    public static final int PASS = 60;
    /**
     *童年
     */
    public static final int CHILD = 6;
    /**
     *少年
     */
    public static final int YOUNG = 17;
    /**
     *青年
     */
    public static final int YOUTH = 40;
    /**
     *中年
     */
    public static final int MIDDLE = 65;

    public static void main(String[] args) {
        UserInfo userInfo = new UserInfo("张三", 84, 80);
        getScoreAgeByName(userInfo,"张三");
        System.out.println(isPass(userInfo));
        System.out.println(call(userInfo));
    }
    public static void getScoreAgeByName(UserInfo userInfo,String name){
        if(name!=null && !"".equals(name) &&userInfo!=null){
            if(name.equals(userInfo.getName())){
                Integer score = userInfo.getScore();
                Integer age = userInfo.getAge();
                System.out.printf("分数：%d，年龄：%d%n",score,age);
            }
        }

    }
    public static String isPass(UserInfo userInfo){
        if(userInfo!=null){
            if (userInfo.getScore()>= PASS){
                return "通过";
            }else{
                return "不合格";
            }
        }
        return "无效学生";
    }

    public static String call(UserInfo userInfo){
        if (userInfo!=null){
            Integer age =userInfo.getAge();
            if (age>0 &&age<= CHILD){
                return "童年";
            }else if (age>CHILD && age <= YOUNG){
                return "少年";
            }else if (age>YOUNG && age<= YOUTH){
                return "青年";
            }else if (age>YOUTH && age<= MIDDLE){
                return "中年";
            }else if (age>MIDDLE){
                return "老年";
            }
        }
        return "无效年龄";
    }
}
